﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using HomeDmsUtils;

namespace Localization
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string s = File.ReadAllText("Source.txt");
            string[] ss = s.Split(new string[] {"\r\n"},  StringSplitOptions.RemoveEmptyEntries);
            dataGridView1.RowCount = ss.Length;
            int i = 0;
            foreach (string t in ss)
            {
                dataGridView1.Rows[i].Cells[0].Value = t;
                dataGridView1.Rows[i].Cells[1].Value = Localizer.CalcKey(t);
                i++;
            }            
        }        

        private void button2_Click(object sender, EventArgs e)
        {
            string[] ss = new string[dataGridView1.Rows.Count];             
            for (int i = 1; i <= dataGridView1.Rows.Count - 1; i++)
            {
                ss[i] = dataGridView1.Rows[i].Cells[1].Value + "\t" + dataGridView1.Rows[i].Cells[0].Value + "\t" + dataGridView1.Rows[i].Cells[0].Value;
            }
            File.WriteAllText("Output.txt", string.Join("\r\n", ss));
            process1.StartInfo.FileName = "Output.txt";
            process1.Start();
        }
    }
}
